package com.awaken.content.service.impl;

import com.awaken.content.models.dto.OrderDTO;
import com.awaken.content.models.request.OrderRequest;
import com.awaken.content.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 订单服务实现类
 *
 * @author awaken-lin
 */
@Slf4j
@Service
public class OrderServiceImpl implements OrderService {

    @Override
    public OrderDTO createOrder(OrderRequest request) {
        log.info("创建订单: {}", request);
        OrderDTO order = new OrderDTO();
        order.setId(1L);
        order.setUserId(request.getUserId());
        order.setProductId(request.getProductId());
        order.setAmount(request.getQuantity());
        order.setStatus(1); // 待付款
        order.setCreateTime(LocalDateTime.now());
        return order;
    }

    @Override
    public OrderDTO getOrderById(Long id) {
        log.info("获取订单信息: {}", id);
        OrderDTO order = new OrderDTO();
        order.setId(id);
        order.setUserId(1L);
        order.setProductId(1L);
        order.setAmount(1);
        order.setStatus(1);
        order.setCreateTime(LocalDateTime.now());
        return order;
    }

    @Override
    public List<OrderDTO> getOrdersByUserId(Long userId) {
        log.info("获取用户订单列表: {}", userId);
        List<OrderDTO> orders = new ArrayList<>();
        OrderDTO order = new OrderDTO();
        order.setId(1L);
        order.setUserId(userId);
        order.setProductId(1L);
        order.setAmount(1);
        order.setStatus(1);
        order.setCreateTime(LocalDateTime.now());
        orders.add(order);
        return orders;
    }

    @Override
    public boolean updateOrderStatus(Long orderId, Integer status) {
        log.info("更新订单状态: orderId={}, status={}", orderId, status);
        return true;
    }

    @Override
    public List<OrderDTO> getAllOrders() {
        log.info("获取所有订单列表");
        List<OrderDTO> orders = new ArrayList<>();
        OrderDTO order = new OrderDTO();
        order.setId(1L);
        order.setUserId(1L);
        order.setProductId(1L);
        order.setAmount(1);
        order.setStatus(1);
        order.setCreateTime(LocalDateTime.now());
        orders.add(order);
        return orders;
    }
} 